#define _CRT_SECURE_NO_WARNINGS 1
#include "util.hpp"
#include "data.hpp"
#include "cloud.hpp"

#define BACKUP_FILE "./backup.dat"
#define BACKUP_DIR "./backup/"

void Test()
{
	cloud::FileUtil fu("./");
	std::vector<std::string> arry;
	fu.ScanDirectory(arry);
	cloud::DataManager data(BACKUP_FILE);
	for (auto x : arry)
	{
		data.Insert(x, "adadd");
	}
}


void testcloud()
{
	cloud::Backup backup(BACKUP_DIR, BACKUP_FILE);
	backup.Runmodule();

}

bool Upload(const std::string& filename)
{
	// 1. get all data
	cloud::FileUtil fu(filename);
	std::string body;
	fu.GetContent(body);

	// 2. send data to client
	httplib::Client client(SERVER_ADDR, SERVER_PORT);
	httplib::MultipartFormData item;
	item.content = body;
	item.filename = fu.FileName();
	item.name = "file"; // mark
	item.content_type = "application/octet-stream";

	httplib::MultipartFormDataItems items;
	items.push_back(item);
	auto res = client.Post("/upload", items);
	if (!res || res->status != 200)
	{
		return false;
	}
	return true;
}

int main()
{
	testcloud();
	return 0;
}

